package com.bigcms.controller;

import com.bigcms.domain.User;
import com.bigcms.service.UserService;
import com.bigcms.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("api/v1/pri/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 获取当前用户信息
     * @param request
     * @return
     */
    @RequestMapping("info")
    public JsonData info(HttpServletRequest request){
        Integer uid = (Integer) request.getAttribute("uid");
        User user = userService.getUser(uid);
        return JsonData.Success(user);
    }
}
